package com.example.javaairportflightanalysis.common;


import com.example.javaairportflightanalysis.exception.MyException;
import com.example.javaairportflightanalysis.exception.MyExceptionEnum;
import org.springframework.stereotype.Component;

/**
 * @author shen
 * 常量值
 */
@Component
public class Constant {
    /** request请求头属性 */
    public static final String TOKEN_HEADER ="base-project";
    /** 密码错误次数 */
    String ERROR_COUNT = "base-project:errorCount:";


    public enum checkStatusEnum {
        /**
         * 0-未审核
         * 1-审核通过
         * 2-审核不通过
         */
        NOT_CHECK(0, "未审核"),
        CHECK_PASS(1, "审核通过"),
        CHECK_NOT_PASS(2, "审核不通过"),
        ;
        private int code;
        private String value;

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        checkStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        //利用code码返回一个对应的value枚举
        public static checkStatusEnum codeOf(int code) {
            for (checkStatusEnum orderStatusEnum : values()) {
                if (orderStatusEnum.getCode() == code) {
                    return orderStatusEnum;
                }
            }
            throw new MyException(MyExceptionEnum.NO_ENUM);
        }
    }
}
